﻿using System;
using System.Web;
using System.Web.Mvc;

namespace XSTDZ.ERP.Infrastructure.Authentication
{
    /// <summary>
    /// 不需要制授权访问特性 [任何登陆的用户都可访问]
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
    public class NoAuthorizatedAttribute :FilterAttribute,IAuthorizationFilter
    {
        private string _actionName;
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="actionName">Action Name</param>
        /// <param name="isAllAction">是否是指定Controller下的所有Action [默认：该控制器下所有Acton]</param>
        public NoAuthorizatedAttribute(string actionName = "")
        {
            this._actionName = actionName;
        }
        public string ActionName
        {
            get { return this._actionName; } 
        }


        public void OnAuthorization(AuthorizationContext filterContext)
        {
            filterContext.Result = null;
        }
    }
}
